using DG.Tweening;
using UnityEngine;
using UnityEngine.UI;

public class UI_InGame_Main : MonoBehaviour
{
	public GameObject _GO_定身术;

	[Header("进度条--表现相关")]
	public ItemUI_能量条 _能量条_生命;

	public ItemUI_能量条 _能量条_气力;

	public C_UI_蓄力 _C_蓄力;

	public ItemUI_能量条 _能量条_酒;

	[Header("经验--表现相关")]
	public ItemUI_能量条 _能量条_经验;

	public CanvasGroup _CG_等级;

	public Text _Text_等级;

	public Text _Text_经验;

	private CanvasGroup _CG_经验;

	[Header("按钮")]
	public Button _Btn_暂停游戏;

	public MyButton _Btn_棍花;

	public MyButton _Btn_重攻击;

	public Button _Btn_喝酒;

	public Button _Btn_跳跃;

	public Button _Btn_轻攻击;

	public Button _Btn_闪避;

	public Button _Btn_定身术;

	public MyButton _MyBtn_喝酒;

	public MyButton _MyBtn_跳跃;

	public MyButton _MyBtn_轻攻击;

	public MyButton _MyBtn_闪避;

	public MyButton _MyBtn_定身术;

	public Image _Img_定身术;

	public MyButton _MyBtn_快速升级;

	public Tween _tw_定身术CD;

	private Color co_Text_经验;

	private void Start()
	{
		_CG_经验 = _能量条_经验.GetComponent<CanvasGroup>();
		_CG_经验.alpha = 0f;
		_CG_等级.alpha = 0f;
		_Btn_暂停游戏.onClick.AddListener(delegate
		{
			MonoSingleton<GameManager>.Instance.F_暂停游戏();
		});
		_Btn_棍花._Down += MonoSingleton<GameManager>.Instance.F_棍花Down;
		_Btn_棍花._Up += MonoSingleton<GameManager>.Instance.F_棍花Up;
		_Btn_重攻击._Down += MonoSingleton<GameManager>.Instance.F_重攻击Down;
		_Btn_重攻击._Up += MonoSingleton<GameManager>.Instance.F_重攻击Up;
		_MyBtn_喝酒._Down += MonoSingleton<GameManager>.Instance.F_喝酒;
		_MyBtn_跳跃._Down += MonoSingleton<GameManager>.Instance.F_跳跃;
		_MyBtn_轻攻击._Down += MonoSingleton<GameManager>.Instance.F_轻攻击;
		_MyBtn_闪避._Down += MonoSingleton<GameManager>.Instance.F_翻滚;
		_MyBtn_定身术._Down += MonoSingleton<GameManager>.Instance.F_定身术;
		_MyBtn_快速升级._Down += MonoSingleton<GameManager>.Instance.F_快速升级;
	}

	public void F_显示()
	{
		if ((bool)_GO_定身术)
		{
			_GO_定身术.gameObject.SetActive(MonoSingleton<MyDataManager>.Instance._PlayerData._教程_定身术教程);
		}
	}

	public void F_显示定身术()
	{
		_GO_定身术.gameObject.SetActive(value: true);
	}

	public void F_UI_定身术CD(float time)
	{
		_tw_定身术CD?.Kill();
		_Img_定身术.fillAmount = 0f;
		_tw_定身术CD = _Img_定身术.DOFillAmount(1f, time).SetEase(Ease.Linear);
	}

	public void F_注册玩家时绑定事件(PlayerController pc)
	{
		pc._On_Curr生命_Change += delegate(float curr, float max)
		{
			_能量条_生命.F_SetVal(curr, max);
		};
		pc._On_Curr气力_Change += delegate(float curr, float max)
		{
			_能量条_气力.F_SetVal(curr, max);
		};
		pc._On_Curr蓄力_Change += delegate(float curr, float max)
		{
			_C_蓄力.F_SetVal(curr, max);
		};
		pc._On_Curr豆子_Change += delegate(int val)
		{
			_C_蓄力.F_Set豆子(val);
		};
		pc._On_Curr酒_Change += delegate(float curr, float max)
		{
			_能量条_酒.F_SetVal(curr, max);
		};
		pc._On_Curr等级_Change += delegate(int val)
		{
			_Text_等级.text = val.ToString();
			_C_蓄力._豆子锁1.SetActive(val < 3);
			_C_蓄力._豆子锁2.SetActive(val < 6);
			_CG_等级.DOKill();
			Sequence s2 = DOTween.Sequence();
			s2.Append(_CG_等级.DOFade(1f, 0.3f));
			s2.AppendInterval(3f);
			s2.Append(_CG_等级.DOFade(0f, 0.3f));
		};
		pc._On_Curr经验_Change += delegate(float curr, float max, float step)
		{
			if (step == -1f)
			{
				_Text_经验.text = "";
				_能量条_经验.F_SetVal(curr, max);
			}
			else
			{
				_Text_经验.text = "+" + step;
				_能量条_经验.F_SetVal(curr, max);
				_CG_经验.DOKill();
				Sequence s = DOTween.Sequence();
				s.Append(_CG_经验.DOFade(1f, 0.3f));
				s.AppendInterval(3f);
				s.Append(_CG_经验.DOFade(0f, 0.3f));
			}
		};
	}

	public void F_暂停游戏()
	{
		_CG_等级.alpha = 1f;
		_CG_经验.alpha = 1f;
		co_Text_经验 = _Text_经验.color;
		co_Text_经验.a = 0f;
		_Text_经验.color = co_Text_经验;
	}

	public void F_继续游戏()
	{
		_CG_等级.alpha = 0f;
		_CG_经验.alpha = 0f;
		co_Text_经验.a = 1f;
		_Text_经验.color = co_Text_经验;
	}
}
